#include<iostream>
using namespace std;

int n;
int a[101];
bool fl = false;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    
    for (int i = 1; i <= n - 2; ++i) {
        if (a[i] == a[i + 1] && a[i] == a[i + 2]) {
            fl = true;
        }
    }
    
    puts(fl ? "Yes" : "No");
    return 0;
}